import torch
import torch.nn.functional as F

x = torch.tensor([[3.0,3.0,3.0]],requires_grad=True)
z = F.softmax(x,dim = 1)
# print(y)
# z = F.log_softmax(x,dim=1)
# print(-z)
# l = torch.nn.NLLLoss()
# loss = l(y,-z)
# print(loss)
func = torch.nn.LogSoftmax(dim=1)
y = func(x)
L = torch.nn.NLLLoss()
loss = L(y,torch.tensor([2]))
loss.backward()
print(loss)